package com.caiyouxi.user.service;

import com.caiyouxi.common.service.BaseService;
import com.caiyouxi.common.util.Log;
import com.caiyouxi.user.mapper.UserReservedMapper;
import com.caiyouxi.user.model.UserReserved;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserReservedService extends BaseService{

    @Autowired
    UserReservedMapper userReservedMapper;

    public UserReserved get_user_reserved_by_id(Integer id) {
        String redis_key = "UserReserved_"+id;
        Log.d("search redis..."+redis_key);
        UserReserved db_bean = (UserReserved) redisService.get(redis_key);
        if (null == db_bean){
            Log.d("search db...");
            db_bean  = userReservedMapper.get_user_reserved_by_id(id);
            redisService.set(redis_key,db_bean);
        }
        return  db_bean;
    }
    
    public UserReserved get_user_reserved_by_user_id(String user_id) {
        String redis_key = "UserReserved_"+user_id;
        Log.d("search redis..."+redis_key);
        UserReserved db_bean = (UserReserved) redisService.get(redis_key);
        if (null == db_bean){
            Log.d("search db...");
            db_bean  = userReservedMapper.get_user_reserved_by_user_id(user_id);
            redisService.set(redis_key,db_bean);
        }
        return  db_bean;
    }

}
